home *** CD-ROM | disk | FTP | other *** search
- Path: newsxfer2.itd.umich.edu!caen!news-server!manowar
- From: manowar@engin.umich.edu (Krisztian Flautner)
- Newsgroups: comp.lang.c++
- Subject: Inheritance and function signatures
- Date: 11 Mar 1996 18:20:10 GMT
- Organization: University of Michigan
- Distribution: world
- Message-ID: <MANOWAR.96Mar11132010@dilo.engin.umich.edu>
- NNTP-Posting-Host: dilo.engin.umich.edu
-
-
-
- Take the following example:
-
- #include <iostream.h>
-
-
- class A {
- public:
- virtual void print();
- virtual void print(int a, int b) = 0;
- };
-
- class B : public A {
- public:
- void print(int a, int b);
- };
-
-
-
-
- void A::print()
- {
- cout << "A::print()" << endl;
- }
-
- void B::print(int a, int b)
- {
- cout << "B::print(int " << a << ", int " << b << ")" << endl;
- }
-
- main()
- {
- B* bb;
-
- bb = new B();
-
- bb->print();
- }
-
-
- I was surprised to see that the call to bb->print() causes an error using
- several compilers. G++ produces the following error message:
-
- t.cc: In function `int main()':
- t.cc:34: too few arguments for method `void B::print(int, int)'
-
- It seems that function signitures are not properly inherited. Is this
- a bug or a feature ?
-
-
-
- Thanks, -- Kris
-
-
-